package com.gui.reflection;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

@Deprecated(since = "1.5")
public class ReflectionEntity{

    private String id;

    private Double height;

    private Double weight;

    private Map<String, Object> attribute;

    static {
        System.out.println("我是静态代码块，我被执行啦......");
    }

    public ReflectionEntity(Double height, Double weight) {
        this.height = height;
        this.weight = weight;
    }

    private Map<String, Object> getBmi() {
        if (attribute == null) {
            attribute = new HashMap<>();
        }
        DecimalFormat df = new DecimalFormat(".00");
        attribute.put("bmi", df.format(this.weight / (this.height * this.height)));
        return attribute;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Double getHeight() {
        return height;
    }

    public void setHeight(Double height) {
        this.height = height;
    }

    public Double getWeight() {
        return weight;
    }

    public void setWeight(Double weight) {
        this.weight = weight;
    }

    public void setAttribute(Map<String, Object> attribute) {
        this.attribute = attribute;
    }

    @Override
    public String toString() {
        return "ReflectionEntity{" +
                "id='" + id + '\'' +
                ", height=" + height +
                ", weight=" + weight +
                ", attribute=" + attribute +
                '}';
    }
}
